#include "StdAfx.h"
#include "User.h"

namespace wlog {

	Hashtable^ User::GetFields(void)
	{
		Hashtable^ fields = gcnew Hashtable;
		fields->Add("name", BaseModel::SafeValue(this->name));
		fields->Add("password", this->password);
		fields->Add("adm", this->adm);
		fields->Add("date_login", this->date_login);
		fields->Add("active", this->active);

		this->f_req = gcnew ArrayList;
		this->f_req->Add("name");

		this->VerifyFields(fields);

		return fields;
	}


	ArrayList^ User::GetAll(void)
	{
		return this->db->CreateQuery(this->ToString())
					   //->Order("active, alert_time")
					   ->GetAll();
	}

	Hashtable^ User::GetItemByName(String^ name)
	{
		return this->db->CreateQuery(this->ToString())
					   //->Order("active, alert_time")
					   ->AndWhere("name = ", name)
					   ->GetRow();
	}


}